<template>
  <div class="myDiv">
    <!-- 军队转业干部 -->
    <el-card class="box-card secordCard" shadow="never">
      <div slot="header" class="clearfix">
        <span>军队转业干部信息</span>
        <!-- <el-button style="float: right; padding: 3px 0" type="text">收起</el-button> -->
      </div>
      <div>
        <el-form :model="form" ref="form" :rules="cadresRules" :inline="true" class="formWidth" label-width="140px">
          <el-row :gutter="10">
            <el-col :span="8">
              <el-form-item label="入伍时间" prop="enlistedDate">
                <el-date-picker clearable size="small"
                  v-model="form.enlistedDate"
                  type="date"
                  value-format="yyyy-MM-dd"
                  placeholder="选择入伍时间">
                </el-date-picker>
              </el-form-item>
            </el-col>
            <el-col :span="8">
             <el-form-item label="退役时间" prop="retirementDate">
                <el-date-picker clearable size="small"
                  v-model="form.retirementDate"
                  type="date"
                  value-format="yyyy-MM-dd"
                  placeholder="选择退役时间">
                </el-date-picker>
              </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-form-item label="原部队代号" prop="originalUnitCode">
                <el-input v-model="form.originalUnitCode" placeholder="请输入原部队代号" />
              </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-form-item label="指转业前职务" prop="originalRank">
                <el-input v-model="form.originalRank" placeholder="请输入指转业前职务" />
              </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-form-item label="转业证件号码" prop="transferCertificateCode">
                <el-input v-model="form.transferCertificateCode" placeholder="请输入转业证件号码" />
              </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-form-item label="立功受奖情况" prop="honour">
                <el-select v-model="form.honour" placeholder="请选择立功受奖情况">
                  <el-option
                    v-for="dict in honourOptions"
                    :key="dict.dictValue"
                    :label="dict.dictLabel"
                    :value="dict.dictValue"
                  ></el-option>
                </el-select>
              </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-form-item label="安置方式" prop="arrangeWay">
                <el-select v-model="form.arrangeWay" placeholder="请选择安置方式">
                  <el-option
                    v-for="dict in arrangeWayOptions"
                    :key="dict.dictValue"
                    :label="dict.dictLabel"
                    :value="parseInt(dict.dictValue)"
                  ></el-option>
                </el-select>
              </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-form-item label="安置地" prop="arrangePlace">
                <el-input v-model="form.arrangePlace" placeholder="请输入安置地 省市县/区" />
              </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-form-item label="安置单位名称" prop="arrangeUnit">
                <el-input v-model="form.arrangeUnit" placeholder="请输入安置单位名称" />
              </el-form-item>
            </el-col>
            <el-col :span="8">
               <el-form-item label="安置单位性质" prop="arrangeUnitType">
                <el-select v-model="form.arrangeUnitType" placeholder="请选择安置单位性质">
                  <el-option
                    v-for="dict in arrangeUnitTypeOptions"
                    :key="dict.dictValue"
                    :label="dict.dictLabel"
                    :value="parseInt(dict.dictValue)"
                  ></el-option>
                </el-select>
              </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-form-item label="安置日期" prop="arrangeDate">
                <el-date-picker clearable size="small"
                    v-model="form.arrangeDate"
                    type="date"
                    value-format="yyyy-MM-dd"
                    placeholder="选择安置日期">
                </el-date-picker>
              </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-form-item label="现就业状况" prop="employmentSituation">
                <el-select v-model="form.employmentSituation" placeholder="请选择现就业状况">
                  <el-option
                    v-for="dict in employmentSituationOptions"
                    :key="dict.dictValue"
                    :label="dict.dictLabel"
                    :value="parseInt(dict.dictValue)"
                  ></el-option>
                </el-select>
              </el-form-item>
            </el-col>
          </el-row>
        </el-form>
      </div>
    </el-card>
  </div>
</template>

<script>
export default {
  name: "cadresCard",
  data(){
    return {
      // 立功受奖情况字典
      honourOptions: [],
       // 安置方式字典
      arrangeWayOptions: [],
      // 安置单位性质字典
      arrangeUnitTypeOptions: [],
      // 现就业状况字典
      employmentSituationOptions: [],
      form:{ // 军队转业干部表单
      },
      cadresRules:{ // 军队转业干部表单校验
         enlistedDate: [
          { required: true, message: "入伍时间不能为空", trigger: "blur" }
        ],
        retirementDate: [
          { required: true, message: "退役时间不能为空", trigger: "blur" }
        ],
        militaryAge: [
          { required: true, message: "军龄 自动生成：退役时间-入伍时间往上取整不能为空", trigger: "blur" }
        ],
      }
    }
  },
  props:{
    soldierId: String,
  },
  created(){
    // 军队转业干部
    this.getDicts("honour").then(response => {
      this.honourOptions = response.data;
    });
    this.getDicts("arrange_way").then(response => {
      this.arrangeWayOptions = response.data;
    });
    this.getDicts("arrange_property").then(response => {
      this.arrangeUnitTypeOptions = response.data;
    });
    this.getDicts("employment_situation").then(response => {
      this.employmentSituationOptions = response.data;
    });
  },
  mounted(){
    this.form.soldierId = this.soldierId
  },
  methods:{
    validateForm(){
      return new Promise((resolve , reject) => {
      this.$refs.form.validate(valid => {
        if (valid) {
          resolve();
        } else reject();
      });
    })
    }
  },
}
</script>
<style lang="scss" scoped>
.box-card{
  margin-bottom: 16px;
}
::v-deep .secordCard .el-form-item__content {
   height: 36px;
}
</style>